﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace test._99_test.time._2012_03_26_142734
{
    public partial class Form_chart : Form
    {
        public Form_chart()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            chart1.ChartAreas.Clear();
            ChartArea c1 = new ChartArea();
            chart1.ChartAreas.Add(c1);
            //Series s1 = new Series();

            DataTable dt1 = new DataTable();
            dt1.Columns.Add("数");
            dt1.Columns.Add("平方");

            for (int i = 0; i < 10; i++)
            {
                DataRow dr1 = dt1.NewRow();
                dr1[0] = i.ToString();
                dr1[1] = (i * i).ToString();
                dt1.Rows.Add(dr1);

            }

            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.DataSource = dt1;
            chart1.Series[0].XValueMember = "数";
            chart1.Series[0].YValueMembers = "平方";
            chart1.DataBind();


          

        }

        private void chart1_MouseHover(object sender, EventArgs e)
        {

        }

        private void chart1_MouseMove(object sender, MouseEventArgs e)
        {

        }

        private void chart1_DoubleClick(object sender, EventArgs e)
        {

        }

        private void chart1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //MessageBox.Show("1");
            HitTestResult result = chart1.HitTest(e.X, e.Y);

            if (result.ChartElementType == ChartElementType.DataPoint)
            {
                MessageBox.Show("1");
                //Create Dialog
                //Dialog dlg = new Dialog();

                ////Initialize members
                //dlg.ChartRef = Chart1;
                //dlg.pointIndex = result.PointIndex;

                //// Show dialog
                //dlg.Show();

            }

        }

        private void Form_chart_Load(object sender, EventArgs e)
        {

        }
    }
}
